package com.nb.customletternavigationbar;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private TextView mTvLetterCenter;
    private CustomLetterNavigationBar mLetterBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mTvLetterCenter = findViewById(R.id.tv_letter_center);
        mLetterBar = findViewById(R.id.letter_bar);
        mLetterBar.setOnLetterTouchListener((letter, isTouch) -> {
            if (isTouch) {
                mTvLetterCenter.setText(letter);
                mTvLetterCenter.setVisibility(View.VISIBLE);
            } else {
                //700毫秒后消失
                mTvLetterCenter.postDelayed(() -> mTvLetterCenter.setVisibility(View.GONE), 700);
            }
        });
    }
}